package com.game.logic.items.prop;

import com.coment.cfg.luban.Tables;
import com.coment.cfg.luban.items.PropCfg;
import com.coment.game.fight.AttributeManagerLogic;
import com.coment.game.fight.Attrs;
import com.coment.po.UserRolesProp;
import com.xs.action.exection.ActionException;

public class UserRolesPropLogic {

    /// 使用道具 ->返回对应的属性
    public static Attrs useProp(UserRolesProp userRolesProp, Integer propId, Integer number) {
        PropCfg propCfg = Tables.cfg.get_tbpropcfg().get(propId);
        double usageLimit = propCfg.usageLimit;
        Integer merge = userRolesProp.useRecord.merge(propId, number, Integer::sum);
        if (merge > usageLimit) throw new ActionException("道具%s已到上限".formatted(propId));
        return AttributeManagerLogic.obtainCfgAttrs(propCfg);
    }
}
